package com.dayu.web.controller.recovery;

import java.util.List;

import com.dayu.common.annotation.RepeatSubmit;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.recovery.domain.RecoveryBlacklist;
import com.dayu.recovery.service.IRecoveryBlacklistService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 商品黑名单Controller
 * 
 * @author HK
 * @date 2024-01-06
 */
@RestController
@RequestMapping("/recovery/blacklist")
public class RecoveryBlacklistController extends BaseController
{
    @Resource
    private IRecoveryBlacklistService recoveryBlacklistService;

    /**
     * 查询商品黑名单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RecoveryBlacklist recoveryBlacklist)
    {
        startPage();
        List<RecoveryBlacklist> list = recoveryBlacklistService.selectRecoveryBlacklistList(recoveryBlacklist);
        return getDataTable(list);
    }

    /**
     * 新增商品黑名单
     */
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@RequestBody RecoveryBlacklist recoveryBlacklist)
    {
        return toAjax(recoveryBlacklistService.insertRecoveryBlacklist(recoveryBlacklist));
    }

    /**
     * 删除商品黑名单
     */
    @PreAuthorize("@ss.hasPermi('recovery:blacklist:remove')")
    @Log(title = "商品黑名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(recoveryBlacklistService.deleteRecoveryBlacklistByIds(ids));
    }
}
